package edu.hebeu.evil.freshmenguide.Fragment;

import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import edu.hebeu.evil.freshmenguide.R;

/********************************************
 * 工程名：FreshmenGuide
 * 包名：edu.hebeu.evil.freshmenguide.Fragment
 * 时间：16-7-21 上午9:32
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：邯郸美景的Fragment
 ********************************************/
public class HanDanViewFragment extends Fragment
{
    private View view;
    private static HanDanViewFragment hanDanViewFragment;

    private ImageView imageView;
    private TextView titleTextView;
    private TextView textView;

    private int imgRes;
    private String title;
    private int stringRes;


    public static HanDanViewFragment newInstance(@DrawableRes int imgRes
            , String title, @StringRes int stringRes)
    {
        hanDanViewFragment = new HanDanViewFragment();

        hanDanViewFragment.imgRes = imgRes;
        hanDanViewFragment.title = title;
        hanDanViewFragment.stringRes = stringRes;

        return hanDanViewFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
    {
        view = inflater.inflate(R.layout.handanview_fragment, container, false);
        initView(view);

        Glide.with(getContext()).load(imgRes).into(imageView);
        titleTextView.setText(title);
        textView.setText(stringRes);
        return view;
    }

    /**
     * 初始化控件
     *
     * @param view
     */
    private void initView(View view)
    {
        imageView = (ImageView) view.findViewById(R.id.imageView);
        titleTextView = (TextView) view.findViewById(R.id.title);
        textView = (TextView) view.findViewById(R.id.textView);
    }
}
